package com.noodles.mall.vo;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.noodles.mall.entity.Item;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.List;

@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class PageVo<T> implements Serializable {
    private long current;
    private long size;
    private List<T> records;
    private long total;

    public static<T> PageVo<T> getPageVo(Page<T> page){
        PageVo<T> pageVo = new PageVo<>();
        BeanUtils.copyProperties(page, pageVo);
        return pageVo;
    }
}

